﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<Excell_On_Services.ViewModels.OrdersDisplayModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Index

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<p class="mc_title">Managerment Orders</p>
    <div class="content-box"><!-- Start Content Box -->

        <div class="content-box-header">
        <% using (Html.BeginForm("SearchOrders", "Order")){ %>

                <%var options = new List<SelectListItem>();
                    options.Add(new SelectListItem { Value = "1", Text = "by Client Name", Selected = true});
                    options.Add(new SelectListItem { Value = "2", Text = "By Status" });
                    options.Add(new SelectListItem { Value = "3", Text = "By Order Date"});
                var checkList = new List<SelectListItem>();
                    checkList.Add(new SelectListItem { Value= "true", Text = "Approved"});
                    checkList.Add(new SelectListItem { Value= "false", Text = "Wait",Selected = true});
                %>
                <%:Html.DropDownList("ddlType", new SelectList(options,"Value","Text"), new {id = "tText", onChange ="ChangeTypeSearch();"})%>
                Enter to Search :&nbsp;&nbsp;
                <%:Html.TextBox("txtSearch", "", new { id = "txtSearch", @class="current_search"})%> &nbsp;&nbsp;
                <%:Html.TextBox("tDate", "", new { id = "tDate", @class = "current_search hidden", onclick = "displayDatePicker('tDate', this);" })%> &nbsp;&nbsp;
                <%:Html.DropDownList("ddlCheck", new SelectList(checkList, "Value", "Text"), new { id = "tCheck", @class = "current_search hidden" })%>

                <input type="submit" value = "Search" class="button_user"/>
			<%} %>
		</div>
        <div class="content-box-content">
			   
		    <div class="tab-content default-tab" id="tab1"> <!-- This is the target div. id must match the href of this div's tab -->
					
			    <%--<div class="notification attention png_bg">
				    <a href="#" class="close"><img src="../../Content/images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
				    <div class="warning_text">
					    This is a Content Box. You can put whatever you want in it. By the way, you can close this notification with the top-right cross.
				    </div>
			    </div>--%>
                <%using (Html.BeginForm("ApplyToSelected", "Order", FormMethod.Post))
                {%>
                <table width="100%">
							
				    <thead style="color:#333333;">
					    <tr>
						    <th>S.No</th>
						    <th>ID</th>
                            <th>Client Name</th>
                            <th>Client Phone</th>
                            <th>Client Email</th>
                            <th>Order Date</th>
                            <th>Total Money</th>
                            <th> Status</th>
					    </tr>
								
				    </thead>

                    <tfoot>
					    <tr>
						    <td colspan="6">
							    <!--<div class="bulk-actions align-left">
								    <select name="dropdown">
									    <option value="option1">Choose an action...</option>
									    <option value="option2">Edit</option>
									    <option value="option3">Delete</option>
								    </select>
								    <a class="button" href="#">Apply to selected</a>
							    </div>-->

							    <div class="pagination">
								    <% Html.RenderPartial("Pager", Model.PagerModel); %>
							    </div> <!-- End .pagination -->
							    <div class="clear"></div>
						    </td>
					    </tr>
				    </tfoot>

                    <tbody>
                    <% int i = 1; %>
                    <% foreach (var item in Model.Orders) { %>
                        <tr>
                            <td><%=i++ %></td>
                            <td>
                                <%: item.OrderID %>
                            </td>
                            <td>
                                <%: item.Client.CompanyName %>
                            </td>
                            <td>
                                <%: item.Client.Phone %>
                            </td>
                            <td>
                                <%: Membership.GetUser(item.Client.aspnet_Users.UserName).Email %>
                            </td>
                            <td>
                                <%: item.OrderDate %>
                            </td>
                            <td>
                                <%
                                    decimal totalMoney = 0;
                                    foreach (var detail in item.OrderDetails)
                                    {
                                        totalMoney += detail.Quantity * detail.Price * (long)((TimeSpan)(detail.EndDate - detail.StartDate)).TotalDays;
                                    } %>
                                    <% = totalMoney.ToString("c") %>
                            </td>
                            <td>
                                <%:Html.CheckBox("lblcheckBox",(bool)item.Status)%>
                
                                <%:item.Status %>
                            </td>
                            <td>
                                <%: Html.ActionLink("Details", "Details", new { id=item.OrderID }) %>

                            </td>
                        </tr>
                    </tbody>
                    <% } %>
                </table>
                <% } %>
            </div>
        </div>
    </div>
</asp:Content>
